package com.zhu.instructions.constants;


import com.zhu.instructions.base.Index8Instruction;
import com.zhu.rtda.Frame;
/**
 * bipush: 将一个 byte 值（-128~127）带符号扩展为 int 并压入操作数栈
 *
 * 格式：bipush <byte>
 * 示例：bipush 100 → 将 100 压入栈
 */
public class BIPUSH extends Index8Instruction {

    @Override
    public void execute(Frame frame) {
        // 从操作数中读取一个 byte，自动扩展为 int
        byte val = (byte) this.index;
        frame.getOperandStack().pushInt(val);
    }

    @Override
    public String toString() {
        return "bipush " + (byte) this.index;
    }
}
